package com.boc.langxiang.presenter.shop;

import com.boc.langxiang.contract.shop.FilterView;
import com.boc.langxiang.entity.request.ProductTypeRequest;
import com.boc.langxiang.entity.response.BaseResponse;
import com.boc.langxiang.entity.response.DepthContent;
import com.boc.langxiang.net.HandleErrorSubscriber;

import rx.android.schedulers.AndroidSchedulers;
import rx.schedulers.Schedulers;

/**
 * Created by Li Guoxi on 2016/6/29.
 */
public class DepthFilterPresenter extends SuperPresenter {

    private FilterView mView;

    public DepthFilterPresenter(FilterView view) {
        super(view);
        this.mView = view;
    }

    public void getFilters() {
        mView.showLoading();
        ProductTypeRequest request = new ProductTypeRequest();
        request.setDepth(String.valueOf(0));
        mService.getDepthList(request.params())
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .unsubscribeOn(Schedulers.io())
                .subscribe(new HandleErrorSubscriber<BaseResponse<DepthContent>>(mView) {
                    @Override
                    public void onSuccess(BaseResponse<DepthContent> response) {
                        mView.hideLoading();
                        mView.getListSuccess(response.getContent().getRes());
                    }
                });
    }

}
